import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:smart_devices/routes/index.dart';
import 'package:smart_devices/utils/colors.dart';
import 'package:smart_devices/utils/log.dart';
import 'package:smart_devices/utils/styles.dart';

import 'bruno/src/l10n/brn_intl.dart';
import 'global.dart';

main() {
  WidgetsFlutterBinding.ensureInitialized();
  Global.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
      statusBarIconBrightness: Brightness.light,
      statusBarColor: Colors.transparent,
    ));
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      showSemanticsDebugger: false,
      title: '智慧设备',
      locale: const Locale('zh', 'CN'),
      fallbackLocale: const Locale('en', 'US'),
      supportedLocales: const [Locale('zh', 'CN'), Locale('en', 'US')],
      localizationsDelegates: [
        RefreshLocalizations.delegate,
        BrnLocalizationDelegate.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      transitionDuration: const Duration(milliseconds: 500),
      defaultTransition: Transition.cupertino,
      initialRoute: Routes.home,
      getPages: Routes.pages,
      theme: ThemeData(
          fontFamily: 'Regular',
          useMaterial3: true,
          brightness: Brightness.dark,
          tabBarTheme: const TabBarTheme(dividerColor: Colors.transparent),
          bottomNavigationBarTheme:
              const BottomNavigationBarThemeData(backgroundColor: Colors.white),
          appBarTheme: AppBarTheme(
              iconTheme: const IconThemeData(
                size: 15,
                opacity: 1,
                color: Colors.transparent,
              ),
              backgroundColor:
                  ColorsUtils.parseColorFromHexString(ColorsUtils.color0052),
              elevation: 0,
              titleTextStyle: StylesUtils.customTextStyle(
                  fontSize: 18, fontWeight: FontWeight.w700),
              centerTitle: true,
              titleSpacing: 0),
          textButtonTheme: const TextButtonThemeData(
              style: ButtonStyle(
                  minimumSize: MaterialStatePropertyAll(Size.zero),
                  padding: MaterialStatePropertyAll(EdgeInsets.zero),
                  tapTargetSize: MaterialTapTargetSize.shrinkWrap)),
          bottomSheetTheme: const BottomSheetThemeData(elevation: 0),
          colorScheme: ColorScheme.light(
            brightness: Brightness.dark,
            background:
                ColorsUtils.parseColorFromHexString(ColorsUtils.colorF6f6),
          )),
      builder: EasyLoading.init(),
      logWriterCallback: LogUtils.writeFromGetx,
    );
  }
}
